﻿@model dai_hoc_tuong_lai.Areas.Admin.Models.UserModel
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestUser",
        OnBegin = "show_Loading",
    };
}
<script type="text/javascript">

    function completedAjaxRequestUser(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        $('#box-busy').fadeOut('medium', function () {
            $('#box-busy').css('display', 'none');
        });

        if (returnObj.Status == "success") {
            if (returnObj.Message != null) {
                makeSuccessHighlightUser(returnObj.Message);
            }
            else if (returnObj.RedirectUrl != null) {
                window.location.href = returnObj.RedirectUrl;
            }
        } else {
            makeErrorHighlightUser(returnObj.Message);
        }

        return false;
    }

    function makeErrorHighlightUser(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span><strong>Alert: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        $highlight.delay(4000).fadeOut(500);
    }

    function makeSuccessHighlightUser(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong>Success: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        //$highlight.delay(4000).fadeOut(500);
    }

</script>
@using (Ajax.BeginForm("AddOrUpdate", "Admin", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    <div class="section-header">
        <dl class="submit">
            <input type="submit" name="submit" id="submit" value="Cập nhật" class="NFButton">
        </dl>
    </div>
    <div class="warning-area">
    </div>
    <div id="tabasAddCategory">
        <div id="tabs-1">
            <table>
                <tr>
                    <td colspan="2">
                        @Html.HiddenFor(model => model.Id, new { id = "Id" })
                         @Html.HiddenFor(model => model.Email)
                        @Html.HiddenFor(model => model.Pass)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Name, "Tên User"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.Name, new { @style = "width:500px" })
                        @Html.ValidationMessageFor(model => model.Name)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Email, "Email"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.Email, new { @style = "width:500px", disabled = "disabled" })
                        @Html.ValidationMessageFor(model => model.Email)
                    </td>
                </tr>
                 <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.EmailNew, "New Email"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.EmailNew, new {  @style = "width:500px" })
                        @Html.ValidationMessageFor(model => model.EmailNew)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.Pass, "Pass word"):
                    </td>
                    <td class="adminData">
                        @Html.PasswordFor(model => Model.Pass, new { @Value = Model.Pass, @style = "width:500px", disabled = "disabled" })
                        @Html.ValidationMessageFor(model => model.Pass)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.PassNew, "New Pass word"):
                    </td>
                    <td class="adminData">
                        @Html.PasswordFor(model => Model.PassNew, new { @style = "width:500px" })
                        @Html.ValidationMessageFor(model => model.PassNew)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        @Html.LabelFor(model => model.chucvu, "Chức vụ"):
                    </td>
                    <td class="adminData">
                        @Html.TextBoxFor(model => Model.chucvu, new { @style = "width:500px" })
                        @Html.ValidationMessageFor(model => model.chucvu)
                    </td>
                </tr>
            </table>
        </div>
    </div>
}
